package MusicModel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.GridLayout;

import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.SwingConstants;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.io.File;
import java.util.ArrayList;
import java.awt.Panel;
import java.awt.Font;

import javax.swing.JToggleButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import Beat.BPMObserver;
import Beat.BeatBar;
import Beat.BeatModelInterface;
import Beat.BeatObserver;
import Principal.ControllerInterface;
import Principal.TransparentPanel;

public class MusicMixPad implements ActionListener,  BeatObserver, BPMObserver{

	private static JFrame frame;
	private static JButton botonP,botonB,botonR;
	private JButton Do,Re,Mi,Fa,Sol,La,Si,DoS,Mib,FaS,SolS,Sib;
	private BeatBar beatBar1, beatBar2, beatBar3;
	private JButton btnStart, btnStop, next, prev, Set;
	private JToggleButton botonManual;
	private TransparentPanel panel;
	private JLabel text;
	private String nombre;
	private Secuencia nDo,nRe,nMi,nFa,nSol,nLa,nSi,nDoS,nMib,nFaS,nSolS,nSib;
	private ControllerInterface controller;
	private BeatModelInterface model;
	private JLabel label;
	private JLabel label_1;
	private JLabel labelBombo;
	private JLabel labelPlatillo;
	private JLabel labelRedoblante;
	private JTextField textField;
	private JButton button;
	private JButton button_1;
	private ArrayList<Secuencia> tocadas;
	private Nota notaDo;
	
	public MusicMixPad (ControllerInterface controller, BeatModelInterface model){
		this.controller = controller;
		this.model = model;

		model.registerObserver((BeatObserver)this);
		model.registerObserver((BPMObserver)this);
		//this.frame.setVisible(true);
		//MusicMixPad window = new MusicMixPad(null,null);
		//window.frame.setVisible(true);
		
		initialize();
		
		
		
		
	}
			
	private void initialize() {		
		  // Create and set up the window.
		frame = new JFrame("DJ TEST DRIVE MIX PAD CENTER");
		//frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		//frame.setDefaultCloseOperation(frame.HIDE_ON_CLOSE);
		frame.setVisible(true);
		
		panel = new TransparentPanel();
		panel.setBackgroundImage(new ImageIcon("fondo2.jpg").getImage());
		  
		Component contents = panel;
		frame.getContentPane().add(contents, BorderLayout.CENTER);
		panel.setLayout(null);
		
		 
		nDo= new Nota("Do",0,1);
		nDoS= new Nota("DoS",0,2);
		nRe= new Nota("Re",0,3);
		nMib= new Nota("Mib",0,4);
		nMi= new Nota("Mi",0,5);
		nFa= new Nota("Fa",0,6);
		nFaS= new Nota("FaS",0,7);
		nSol= new Nota("Sol",0,8);
		nSolS= new Nota("SolS",0,9);
		nLa= new Nota("La",0,10);
		nSi= new Nota("Si",0,11);
		nSib= new Nota("Sib",0,12);
		tocadas = new ArrayList<Secuencia>();
		
		//notaDo.setBpm(12);
		nDo.crear();	
		nDoS.crear();
		nRe.crear();
		nMib.crear();
		nMi.crear();
		nFa.crear();
		nFaS.crear();
		nSol.crear();
		nSolS.crear();
		nLa.crear();
		nSi.crear();
		nSib.crear();
		
	
		//////////////////////////////////////////////////////////////////////////////
		//Botones y Acciones
		botonB = new JButton("Bombo");
		botonB.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				//Crear instrumento
				//Reproducir mientras queda apretado
				//Stopear al apagar
				playBombo();
			}
		});
		
		textField = new JTextField();
		textField.setHorizontalAlignment(SwingConstants.CENTER);
		textField.setBounds(67, 219, 113, 32);
		panel.add(textField);
		textField.setColumns(10);
		
		JLabel lblNewLabel = new JLabel("Roland SPD-SX Sampling Pad");
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel.setForeground(Color.LIGHT_GRAY);
		lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 35));
		lblNewLabel.setBounds(212, 11, 462, 83);
		panel.add(lblNewLabel);
		panel.add(botonB);
		botonB.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				
			}
		});
		botonB.setBounds(250, 262, 89, 54);
		
		
		
		
		botonP = new JButton("Platillo");
		botonP.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		panel.add(botonP);
		botonP.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				playPlatillo();
			}
		});
		botonP.setBounds(349, 262, 89, 54); 
		
		
		botonR = new JButton("Redoblante");
		panel.add(botonR);
		botonR.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				playRedoblante();
			}
		});
		botonR.setBounds(448, 262, 87, 53);
		
		
		//TECLAS------------------------------------------
		Do = new JButton("DO");
		Do.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				//notaDo.parar();
				nDo.iniciar();
				//tocadas.add(notaDo);
				
			}
		});
		Do.setFont(new Font("Tahoma", Font.PLAIN, 8));
		Do.setBackground(Color.WHITE);
		Do.setBounds(105, 369, 48, 107);
		panel.add(Do);
		
		Re = new JButton("RE");
		Re.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				nRe.iniciar();
			}
		});
		Re.setFont(new Font("Tahoma", Font.PLAIN, 8));
		Re.setBackground(Color.WHITE);
		Re.setBounds(178, 369, 47, 107);
		panel.add(Re);
		
		Mi = new JButton("MI");
		Mi.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				nMi.iniciar();
			}
		});
		Mi.setFont(new Font("Tahoma", Font.PLAIN, 8));
		Mi.setBackground(Color.WHITE);
		Mi.setBounds(250, 369, 47, 107);
		panel.add(Mi);
		
		Fa = new JButton("FA");
		Fa.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				nFa.iniciar();
			}
		});
		Fa.setFont(new Font("Tahoma", Font.PLAIN, 8));
		Fa.setBackground(Color.WHITE);
		Fa.setBounds(296, 369, 47, 107);
		panel.add(Fa);
		
		Sol = new JButton("Sol");
		Sol.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				nSol.iniciar();
			}
		});
		Sol.setFont(new Font("Tahoma", Font.PLAIN, 8));
		Sol.setBackground(Color.WHITE);
		Sol.setBounds(368, 369, 47, 107);
		panel.add(Sol);
		
		La = new JButton("LA");
		La.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				nLa.iniciar();
			}
		});
		La.setFont(new Font("Tahoma", Font.PLAIN, 8));
		La.setBackground(Color.WHITE);
		La.setBounds(440, 369, 47, 107);
		panel.add(La);
		
		FaS = new JButton("");
		FaS.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				nFaS.iniciar();
			}
		});
		FaS.setBackground(Color.BLACK);
		FaS.setBounds(342, 369, 27, 51);
		panel.add(FaS);
		
		DoS = new JButton("");
		DoS.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				nDoS.iniciar();
			}
		});
		DoS.setBackground(Color.BLACK);
		DoS.setBounds(152, 369, 27, 51);
		panel.add(DoS);
		
		Mib = new JButton("");
		Mib.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				nMib.iniciar();
			}
		});
		Mib.setBackground(Color.BLACK);
		Mib.setBounds(224, 369, 27, 51);
		panel.add(Mib);
		
		SolS = new JButton("");
		SolS.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				nSolS.iniciar();
			}
		});
		SolS.setBackground(Color.BLACK);
		SolS.setBounds(414, 369, 27, 51);
		panel.add(SolS);
		
		Si = new JButton("SI");
		Si.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				nSi.iniciar();
			}
		});
		Si.setFont(new Font("Tahoma", Font.PLAIN, 8));
		Si.setBackground(Color.WHITE);
		Si.setBounds(512, 369, 47, 107);
		panel.add(Si);
		
		Sib = new JButton("");
		Sib.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				nSib.iniciar();
			}
		});
		Sib.setBackground(Color.BLACK);
		Sib.setBounds(486, 369, 27, 51);
		panel.add(Sib);
		 
		
		//Botones Play y Stop--------------------------------------- 
		btnStart = new JButton("Play");
		btnStart.addActionListener(new ActionListener() {
		 	public void actionPerformed(ActionEvent arg0) {
		  		controller.start();
		  	}
		});
		btnStart.setBounds(121, 11, 89, 31);
		panel.add(btnStart);
		  
		btnStop = new JButton("Stop");
		btnStop.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				controller.stop();
		  	}
		});
		btnStop.setBounds(121, 47, 89, 32);
		panel.add(btnStop);
		  
		  
		//BARRA DE PROGRESO-------------------------------------------------------
		    beatBar1 = new BeatBar();
		    beatBar1.setBounds(349, 228, 89, 23);
			panel.add(beatBar1);
			
			beatBar2 = new BeatBar();
			beatBar2.setBounds(446, 228, 89, 23);
			panel.add(beatBar2);
			
			beatBar3 = new BeatBar();
			beatBar3.setBounds(250, 228, 89, 23);
			panel.add(beatBar3);
		  
		  
		  //BOTON MANUAL------------------------------------------------------------
		  botonManual = new JToggleButton("Pad Mode");
		  botonManual.addKeyListener(new KeyAdapter() {
				@Override
				public void keyPressed(KeyEvent tecla) {
					if(tecla.VK_I==tecla.getKeyCode()){
						botonB.setBackground(Color.RED);
						playBombo();
					}
					if(tecla.VK_O==tecla.getKeyCode()){
						botonP.setBackground(Color.BLUE);
						playPlatillo();
					}
					if(tecla.VK_P==tecla.getKeyCode()){
						botonR.setBackground(Color.GREEN);
						playRedoblante();
					}
					if(tecla.VK_Z==tecla.getKeyCode()){
						Do.setBackground(Color.GRAY);
						//Nota DO
						nDo.iniciar();
					}
					if(tecla.VK_X==tecla.getKeyCode()){
						Re.setBackground(Color.GRAY);
						//Nota RE
						nRe.iniciar();
					}
					if(tecla.VK_C==tecla.getKeyCode()){
						Mi.setBackground(Color.GRAY);
						//Nota MI
						nMi.iniciar();
					}
					if(tecla.VK_V==tecla.getKeyCode()){
						Fa.setBackground(Color.GRAY);
						//Nota FA
						nFa.iniciar();
					}
					if(tecla.VK_B==tecla.getKeyCode()){
						Sol.setBackground(Color.GRAY);
						//Nota SOL
						nSol.iniciar();
					}
					if(tecla.VK_N==tecla.getKeyCode()){
						La.setBackground(Color.GRAY);
						//Nota LA
						nLa.iniciar();
					}
					if(tecla.VK_M==tecla.getKeyCode()){
						Si.setBackground(Color.GRAY);
						//Nota SI
						nSi.iniciar();
					}
					if(tecla.VK_S==tecla.getKeyCode()){
						DoS.setBackground(Color.GRAY);
						//Nota DO#
						nDoS.iniciar();
					}
					if(tecla.VK_D==tecla.getKeyCode()){
						Mib.setBackground(Color.GRAY);
						//Nota MIb
						nMib.iniciar();
					}
					if(tecla.VK_G==tecla.getKeyCode()){
						FaS.setBackground(Color.GRAY);
						//Nota FA#
						nFaS.iniciar();
					}
					if(tecla.VK_H==tecla.getKeyCode()){
						SolS.setBackground(Color.GRAY);
						//Nota SOL#
						nSolS.iniciar();
					}
					if(tecla.VK_J==tecla.getKeyCode()){
						Sib.setBackground(Color.GRAY);
						//Nota SIb
						nSib.iniciar();
					}
				}
				@Override
				public void keyReleased(KeyEvent tecla) {
					if(tecla.VK_I==tecla.getKeyCode()){
						botonB.setBackground(null);
					}
					if(tecla.VK_O==tecla.getKeyCode()){
						botonP.setBackground(null);
					}
					if(tecla.VK_P==tecla.getKeyCode()){
						botonR.setBackground(null);
					}
					if(tecla.VK_Z==tecla.getKeyCode()){
						Do.setBackground(Color.WHITE);
						//Nota DO
					}
					if(tecla.VK_X==tecla.getKeyCode()){
						Re.setBackground(Color.WHITE);
						//Nota RE
					}
					if(tecla.VK_C==tecla.getKeyCode()){
						Mi.setBackground(Color.WHITE);
						//Nota MI
					}
					if(tecla.VK_V==tecla.getKeyCode()){
						Fa.setBackground(Color.WHITE);
						//Nota FA
					}
					if(tecla.VK_B==tecla.getKeyCode()){
						Sol.setBackground(Color.WHITE);
						//Nota SOL
					}
					if(tecla.VK_N==tecla.getKeyCode()){
						La.setBackground(Color.WHITE);
						//Nota LA
					}
					if(tecla.VK_M==tecla.getKeyCode()){
						Si.setBackground(Color.WHITE);
						//Nota SI
					}
					if(tecla.VK_S==tecla.getKeyCode()){
						DoS.setBackground(Color.BLACK);
						//Nota DO#
					}
					if(tecla.VK_D==tecla.getKeyCode()){
						Mib.setBackground(Color.BLACK);
						//Nota MIb
					}
					if(tecla.VK_G==tecla.getKeyCode()){
						FaS.setBackground(Color.BLACK);
						//Nota FA#
					}
					if(tecla.VK_H==tecla.getKeyCode()){
						SolS.setBackground(Color.BLACK);
						//Nota SOL#
					}
					if(tecla.VK_J==tecla.getKeyCode()){
						Sib.setBackground(Color.BLACK);
						//Nota SIb
					}
				}
			});
			///botonManual.setBounds(20, 155, 120, 54);
			botonManual.setBounds(10, 11, 98, 68);
			panel.add(botonManual);
			
			JLabel lblBpm = new JLabel("BPM");
			lblBpm.setForeground(Color.GREEN);
			lblBpm.setHorizontalAlignment(SwingConstants.CENTER);
			lblBpm.setFont(new Font("Ebrima", Font.BOLD, 24));
			lblBpm.setBounds(250, 185, 89, 32);
			panel.add(lblBpm);
			
			label = new JLabel("BPM");
			label.setForeground(Color.GREEN);
			label.setHorizontalAlignment(SwingConstants.CENTER);
			label.setFont(new Font("Ebrima", Font.BOLD, 24));
			label.setBounds(349, 185, 89, 32);
			panel.add(label);
			
			label_1 = new JLabel("BPM");
			label_1.setForeground(Color.GREEN);
			label_1.setHorizontalAlignment(SwingConstants.CENTER);
			label_1.setFont(new Font("Ebrima", Font.BOLD, 24));
			label_1.setBounds(446, 185, 89, 32);
			panel.add(label_1);
			
			labelBombo = new JLabel("0");
			labelBombo.setForeground(Color.GREEN);
			labelBombo.setHorizontalAlignment(SwingConstants.CENTER);
			labelBombo.setFont(new Font("Ebrima", Font.BOLD, 24));
			labelBombo.setBounds(250, 155, 89, 32);
			panel.add(labelBombo);
			
			labelPlatillo = new JLabel("0");
			labelPlatillo.setForeground(Color.GREEN);
			labelPlatillo.setHorizontalAlignment(SwingConstants.CENTER);
			labelPlatillo.setFont(new Font("Ebrima", Font.BOLD, 24));
			labelPlatillo.setBounds(349, 155, 89, 32);
			panel.add(labelPlatillo);
			
			labelRedoblante = new JLabel("0");
			labelRedoblante.setForeground(Color.GREEN);
			labelRedoblante.setHorizontalAlignment(SwingConstants.CENTER);
			labelRedoblante.setFont(new Font("Ebrima", Font.BOLD, 24));
			labelRedoblante.setBounds(446, 155, 89, 32);
			panel.add(labelRedoblante);
			
			text = new JLabel("Instrumento: Platillo");
			text.setForeground(Color.GREEN);
			text.setFont(new Font("Tahoma", Font.PLAIN, 13));
			text.setHorizontalAlignment(SwingConstants.CENTER);
			text.setBounds(10, 302, 236, 14);
			panel.add(text);
			
			Set = new JButton("SET");
			Set.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					/*if(textField.getText().equals("")){
						//Si es un platillo, que el label al platillo
			        	if(model.getInstrumentoActual()==1){
			        		labelPlatillo.setText("");
			        	}
			        	//Si es un bombo, que el label al bombo
			        	if(model.getInstrumentoActual()==2){
			        		labelBombo.setText("");
			        	}
			        	//Si es un redoblante, que el label al redoblante
			        	if(model.getInstrumentoActual()==3){
			        		labelRedoblante.setText("");
			        	}
					}else{*/
					if(!textField.getText().equals("")){
						int bpm = Integer.parseInt(textField.getText());
						controller.setBPM(bpm);
			        	//Si es un platillo, que el label al platillo
			        	if(model.getInstrumentoActual()==1){
			        		labelPlatillo.setText(bpm+"");
			        	}
			        	//Si es un bombo, que el label al bombo
			        	if(model.getInstrumentoActual()==2){
			        		labelBombo.setText(bpm+"");
			        	}
			        	//Si es un redoblante, que el label al redoblante
			        	if(model.getInstrumentoActual()==3){
			        		labelRedoblante.setText(bpm+"");
			        	}
					}
				}
			});
			Set.setBounds(67, 255, 113, 42);
			panel.add(Set);
			
			next = new JButton(">>");
			next.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					controller.increaseBPM();
					actualizarNombre();
					actualizarLabel();
				}
			});
			next.setBounds(190, 221, 48, 50);
			panel.add(next);
			
			prev = new JButton("<<");
			prev.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					controller.decreaseBPM();
					actualizarNombre();
					actualizarLabel();
				}
			});
			prev.setBounds(10, 219, 48, 50);
			panel.add(prev);
		
		
		
		
		
		//Fin Botones y Acciones
		////////////////////////////////////////////////////////////////////////////
		
		//Set window size
		frame.setPreferredSize(new Dimension(700,525));
		 
		// Display the window.
		frame.pack();
		//frame.setLocationByPlatform(true);
		frame.setLocation(180,100);
		frame.setVisible(true);
			
}
		
		
		
		
		public static void playBombo(){
			try {
				Clip sonido = AudioSystem.getClip();
				File a = new File("sonidos\\wavB.wav");
				sonido.open(AudioSystem.getAudioInputStream(a));
				sonido.start();
				System.out.println("Dum");
				//Thread.sleep(2000); // 1000 milisegundos (1 segundos)
				//sonido.close();
				}
				catch (Exception tipoerror) {
				System.out.println("" + tipoerror);
				}
		}
		
		public static void playPlatillo(){
			try {
				Clip sonido = AudioSystem.getClip();
				File a = new File("sonidos\\wavP.wav");
				sonido.open(AudioSystem.getAudioInputStream(a));
				sonido.start();
				System.out.println("Tss");
				//Thread.sleep(1200); // 1000 milisegundos (1 segundos)
				//sonido.close();
				}
				catch (Exception tipoerror) {
				System.out.println("" + tipoerror);
				}
		}
		
		public static void playRedoblante(){
			try {
				Clip sonido = AudioSystem.getClip();
				File a = new File("sonidos\\wavR.wav");
				sonido.open(AudioSystem.getAudioInputStream(a));
				sonido.start();
				System.out.println("Tash");
				//Thread.sleep(2000); // 1000 milisegundos (1 segundos)
				//sonido.close();
				}
				catch (Exception tipoerror) {
				System.out.println("" + tipoerror);
				}
		}

		public void createView() {
			// TODO Auto-generated method stub
			// Create all Swing components here
			/*progressBar_1 = new BeatBar();
			progressBar_1.setBounds(250, 228, 89, 23);
			panel.add(progressBar_1);
			
			progressBar_2 = new BeatBar();
			progressBar_2.setBounds(349, 228, 89, 23);
			panel.add(progressBar_2);
			
			progressBar_3 = new BeatBar();
			progressBar_3.setBounds(446, 228, 89, 23);
			panel.add(progressBar_3);
			*/
	        /* viewPanel = new JPanel(new GridLayout(1, 2));
	        viewFrame = new JFrame("View");
	        viewFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	        viewFrame.setBounds(500, 125, 150, 80);
	        viewFrame.setSize(new Dimension(150, 80));
	        bpmOutputLabel = new JLabel("offline", SwingConstants.CENTER);
			beatBar = new BeatBar();
			beatBar.setValue(0);
	        JPanel bpmPanel = new JPanel(new GridLayout(2, 1));
			bpmPanel.add(beatBar);
	        bpmPanel.add(bpmOutputLabel);
	        viewPanel.add(bpmPanel);
	        viewFrame.getContentPane().add(viewPanel, BorderLayout.CENTER);
	        viewFrame.pack();
	        viewFrame.setVisible(true);
	        viewFrame.setLocation(585, 200);*/ /*****************VIEW POSITION*****/
			
			
		}

		public void createControls() {
			// TODO Auto-generated method stub
			
		}

		public void disableStopMenuItem() {
			// TODO Auto-generated method stub
			btnStop.setEnabled(false);
		}

		public void enableStartMenuItem() {
			// TODO Auto-generated method stub
			btnStart.setEnabled(true);
		}

		public void disableStartMenuItem() {
			// TODO Auto-generated method stub
			btnStart.setEnabled(false);
		}

		public void enableStopMenuItem() {
			// TODO Auto-generated method stub
			btnStop.setEnabled(true);
		}
		
		
		public void actionPerformed(ActionEvent event) {
			if (event.getSource() == Set) {
				int bpm = Integer.parseInt(textField.getText());
	        	controller.setBPM(bpm);
			} else if (event.getSource() == next) {
				controller.increaseBPM();
			} else if (event.getSource() == prev) {
				controller.decreaseBPM();
			}
	    }
		
		public void updateBPM() {
			if (model != null) {
				int bpm = model.getBPM();
				if (bpm == 0) {
					if (text != null) {
						text.setText("offline");
					}
				} else {
					if (text != null) {
						//Si es un platillo, que el label al platillo
			        	actualizarNombre();
			        	actualizarLabel();
					}
				}
			}
		}
	  
		private void actualizarLabel() {
			// TODO Auto-generated method stub
			text.setText("Instrumento: "+nombre/*+", BPM: " + model.getBPM()*/);
		}

		public void updateBeat() {
			if(model.getInstrumentoActual()==1){
				if (beatBar1 != null) {
					 beatBar1.setValue(100);
				}
        	}
        	//Si es un bombo, que el label al bombo
        	if(model.getInstrumentoActual()==2){
        		if (beatBar3 != null) {
   				 beatBar3.setValue(100);
        		}
        	}
        	//Si es un redoblante, que el label al redoblante
        	if(model.getInstrumentoActual()==3){
        		if (beatBar2 != null) {
   				 beatBar2.setValue(100);
        		}
        	}
			
			
		}
		public void actualizarNombre() {
			// TODO Auto-generated method stub
			if(model.getInstrumentoActual()==1){
        		nombre = "Platillo";
        	}
        	//Si es un bombo, que el label al bombo
        	if(model.getInstrumentoActual()==2){
        		nombre = "Bombo";
        	}
        	//Si es un redoblante, que el label al redoblante
        	if(model.getInstrumentoActual()==3){
        		nombre = "Redoblante";
        	}
			
		}
}
